package com.example.administrator.DB;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Created by ykbboom on 2016/12/31.
 */

public class DBHelper extends SQLiteOpenHelper {

    public static final String DatabaseName = "xiaoxiaole.db";
    public static final int DatabaseVersion = 1;

    public DBHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        //CursorFactory设置为null,使用默认值
        super(context, DatabaseName, factory, DatabaseVersion);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        //数据库第一次被创建时onCreate会被调用
        //创建user_info+user_point，主键id 体力数 金币数 签到时间;主键id 用户id 计时得分 限步得分
        db.execSQL("CREATE TABLE IF NOT EXISTS user_info (_id INTEGER PRIMARY KEY,body_num Integer," +
                "money_num INTEGER,sign_in_time LONG,user_name VARCHAR)");
        db.execSQL("CREATE TABLE IF NOT EXISTS user_point (_id INTEGER PRIMARY KEY AUTOINCREMENT,user_id Integer," +
                "time_point INTEGER,step_point INTEGER)");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("ALTER TABLE user ADD other STRING");
    }
}
